﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ScheduleMaker.DB.Domain;
using ScheduleMaker.DB.Domain.Core;

namespace ScheduleMaker.DB
{
    //TODO: po czym chcemy szukac?
    public class SubjectDAOSchool : AbstractDAO<SubjectSchool>
    {

        public IList<SubjectSchool> getSubjectsByClassroom(Classroom classroom)
        {
            IList<SubjectSchool> subjects = getAll();
            IList<SubjectSchool> returned = new List<SubjectSchool>();
            foreach (var subject in subjects)
            {
                bool member = true;
                foreach (var eq in subject.Equipments)
                {
                    if (!classroom.Equipments.Contains(eq))
                    {
                        member = false;
                        break;
                    }
                }
                if (member)
                    returned.Add(subject);
            }

            return returned;
        }

    }
}
